package com.xmut.bs.handaccount.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

import com.xmut.bs.handaccount.R;
import com.xmut.bs.handaccount.adapter.OrderPagerAdapter;
import com.xmut.bs.handaccount.base.ToolbarBaseActivity;

import butterknife.BindView;

import static com.xmut.bs.handaccount.base.Constants.PARAM_ORDER_MANAGER;

public class OrderActivity extends ToolbarBaseActivity {

    @BindView(R.id.viewpager)
    ViewPager mViewPager;
    @BindView(R.id.tabs)
    TabLayout mTabLayout;

    public static final String ORDER_TYPE = "type";
    public static final int ORDER_TYPE_ALL = 0;
    public static final int ORDER_TYPE_PAY = 1;
    public static final int ORDER_TYPE_USE = 2;
    public static final int ORDER_TYPE_SERVICE = 3;
    private int type;
    private boolean isManager;

    @Override
    protected int bindLayoutId() {
        return R.layout.fragment_nearby;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        // Create the adapter that will return a fragment for each of the three
        // primary sections of the activity.
        OrderPagerAdapter mSectionsPagerAdapter = new OrderPagerAdapter(getSupportFragmentManager(),isManager);
        mViewPager.setAdapter(mSectionsPagerAdapter);
        mTabLayout.setSelectedTabIndicatorColor(colorPrimary);
        mTabLayout.setTabTextColors(getResources().getColor(R.color.grey500),colorPrimary);
        mTabLayout.setupWithViewPager(mViewPager);
        mViewPager.setCurrentItem(type);
    }

    @Override
    protected void initParams(Intent intent) {
        this.type = intent.getIntExtra(ORDER_TYPE, ORDER_TYPE_ALL);
        this.isManager = intent.getBooleanExtra(PARAM_ORDER_MANAGER, false);
    }

    @Override
    protected String getSubTitle() {
        return "我的订单";
    }
}
